package com.xh.one2one.lesson.service.impl;

import com.xh.one2one.lesson.bean.request.LessonTimesAuditCommentRequest;
import com.xh.one2one.lesson.model.LessonTimesAuditComment;
import com.xh.one2one.lesson.dao.LessonTimesAuditCommentMapper;
import com.xh.one2one.lesson.service.ILessonTimesAuditCommentService;
import com.xh.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xh.core.bean.XhPage;
import com.xh.core.util.StringUtils;
import java.util.List;
/**
 * <p>
 * 备课审核教学计划评价 服务实现类
 * </p>
 *
 * @author TW
 * @since 2021-04-22
 */
@Service
public class LessonTimesAuditCommentServiceImpl extends BaseServiceImpl<LessonTimesAuditCommentMapper, LessonTimesAuditComment> implements ILessonTimesAuditCommentService {
    @Override
    public XhPage queryLessonTimesAuditCommentPage(XhPage page, LessonTimesAuditCommentRequest bean) {
        QueryWrapper qw=new QueryWrapper<LessonTimesAuditComment>();
        //拼装条件
        qw=prepareParams(bean, qw);

        return (XhPage) this.dao.selectPage(page,qw);
    }

    @Override
    public List queryLessonTimesAuditComment(LessonTimesAuditCommentRequest bean) {
        QueryWrapper qw=new QueryWrapper<LessonTimesAuditComment>();
        //拼装条件
        qw=prepareParams(bean, qw);

        return this.dao.selectList(qw);
    }

    @Override
    public LessonTimesAuditComment queryComment(LessonTimesAuditCommentRequest bean) {
        QueryWrapper qw=new QueryWrapper<LessonTimesAuditComment>();
        //拼装条件
        qw=prepareParams(bean, qw);

        return this.dao.selectOne(qw);
    }

    /**
     * 准备条件
     * @param bean
     * @param qw
     */
    private QueryWrapper prepareParams(LessonTimesAuditCommentRequest bean, QueryWrapper qw) {
        if(bean.getIds()!=null&&bean.getIds().length>0){
            qw.in("id",bean.getIds());
        }
        if(!StringUtils.isEmpty(bean.getLessonId())){
            qw.eq("lesson_id",bean.getLessonId());
        }
        if(null != bean.getVersion()){
            qw.eq("version",bean.getVersion());
        }
        return qw;
    }
}
